package com.yx.backstage.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author YangXiong
 */
@Data
@Configuration
@Accessors(chain = true)
public class ALiYunOSSConfig {
    /**
     * oss对外服务的访问域名
     */
    public String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";

    /**
     * 访问身份验证中用到的用户标识
     */
    public String accesskeyid = "LTAI5tFjTFZq29qCZY5AGTrs";
    /**
     * 用户用于加密签名字符串和oss用来验证签名字符串的 密钥
     */
    public String accesskeysecret = "wpuK3x85u3z5GI8hMDs4CaSgXGezx0";
    /**
     * oss的存储空间
     */
    public String buket = "yangxiong001";
    /**
     * 阿里云OSS文件地址
     */
    public String url = "https://yangxiong001.oss-cn-hangzhou.aliyuncs.com/";

    /**
     * 将OSS 客户端交给Spring容器托管
     * @return OSSClint
     */
    @Bean
    public OSS OSSClient() {
        return new OSSClient(endpoint, accesskeyid, accesskeysecret);
    }
}
